package cn.humaohua.study.yanmo_design_pattern.ch13.v3;

public class Waiter {
    /**
     * 持有一个宏命令对象-菜单
     */
    private MenuCommand menuCommand = new MenuCommand();

    /**
     * 点菜
     *
     * @param command 菜【命令】
     */
    public void orderDish(Command command) {
        CookApi hotCook = new HotCook();
        CookApi coolCook = new CoolCook();
        if (command instanceof ChopCommand)
            ((ChopCommand) command).setCook(hotCook);
        else if (command instanceof DuckCommand)
            ((DuckCommand) command).setCook(hotCook);
        else if (command instanceof PorkCommand)
            ((PorkCommand) command).setCook(coolCook);

        this.menuCommand.getCmds().add(command);
    }

    /**
     * 点菜结束
     */
    public void orderOver() {
        this.menuCommand.execute();
    }
}
